package uabc.arduino.pruebas;

import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JFrame;
import javax.swing.JToggleButton;

public class Main {

	public static void main(String[] args) {

		final JFrame frame = new JFrame("JToggle Button Demo");
		frame.setSize(200, 100);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new FlowLayout());

		final JToggleButton jtbButton = new JToggleButton("No");
		jtbButton.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent ev) {
				System.out.println("Item Event " + ev.getStateChange());
				if (ev.getStateChange() == 1)
					jtbButton.setLabel("Si");
				else
					jtbButton.setLabel("No");
			}
		});
		frame.add(jtbButton);
		frame.setVisible(true);
	}
}